Globals in Macros.carp
and
Macro
(and :rest xs)
evaluates the forms xs
one at a time, from left to right. If a form
evaluates to false
, and
returns that value and doesn't evaluate any of the
other expressions, otherwise it returns the value of the last form in xs
.
(and)
returns true
.
c-name
Macro
(c-name sym cname)
Override the identifiers Carp generates for a given symbol in C output.
(defn foo-bar [] 1)
(c-name foo-bar "foo_bar")
cond
Macro
(cond :rest xs)
Executes a block of code if a specified condition is true. Multiple such blocks can be chained.
(cond
(< 10 1) (println "Condition 1 is true")
(> 10 1) (println "Condition 2 is true")
(println "Else branch"))
const-assert
Dynamic
(const-assert expr msg)
Asserts that the expression expr
is true at compile time.
Otherwise it will fail with the message msg
.
The expression must be evaluable at compile time.
defdynamic-once
Macro
(defdynamic-once var expr)
Creates a dynamic variable and sets its value if it's not already defined.
defn-
Macro
(defn- name args form)
Declares a function while marking it as private and hidden.
deprecated
Macro
(deprecated name :rest explanation)
Declares that a binding is deprecated, using an optional explanation.
hidden
Macro
(hidden name)
Mark a binding as hidden, this will make it not print with the 'info' command.
ignore*
Macro
(ignore* :rest forms)
Wraps all forms passed as an argument in a call to ignore
.
implements-all
Macro
(implements-all mod :rest interfaces)
Declares functions in mod with names matching interfaces
as implementations
of those interfaces.
load-and-use
Macro
(load-and-use name)
loads a file and uses the module with in it. Assumes that the filename and module name are the same.
or
Macro
(or :rest xs)
evaluates the forms xs
one at a time, from left to right. If a form
evaluates to true
, or
returns that value and doesn't evaluate any of the
other expressions, otherwise it returns the value of the last form in xs
.
(or)
returns false
.
private
Macro
(private name)
Mark a binding as private, this will make it inaccessible from other modules.
unreachable
Macro
(unreachable msg)
Asserts that a block of code will never be reached. If it is the program will be aborted with an error message.